package GUI.view.outlook;

import java.awt.Color;
import java.awt.Component;

import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
import javax.swing.SwingConstants;
import javax.swing.border.Border;

public class FreeOutlookListRenderer extends DefaultListCellRenderer {

    private final Color selectedColor = FreeUtil.DEFAULT_SELECTION_COLOR;
    private final Border normalBorder = BorderFactory.createEmptyBorder(3, 19, 3, 2);
    private final Border shrinkedBorder = BorderFactory.createEmptyBorder(3, 2, 3, 2);
    private final FreeOutlookList list;
    public FreeOutlookListRenderer(final FreeOutlookList list) {
        super();
        this.list = list;
    }
    /*
    @Override
    public Component getListCellRendererComponent(final JList list,
            final Object value, final int index, final boolean isSelected,
            final boolean cellHasFocus) {
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

        this.setToolTipText(this.getText());
        final FreeOutlookList outlookList = (FreeOutlookList) list;
        if (outlookList.getFreeOutlookBar().getFreeOutlookPane().isShrinked()) {
            this.setBorder(shrinkedBorder);
            this.setText(null);
            this.setHorizontalAlignment(SwingConstants.CENTER);
            this.setIconTextGap(0);
        } else {
            this.setBorder(normalBorder);
            this.setHorizontalAlignment(SwingConstants.LEADING);
            this.setIconTextGap(5);
        }

        if (isSelected) {
            this.setBackground(selectedColor);
        }
        return this;
    }*/
	@Override
	public Component getListCellRendererComponent(final JList list, final Object value,
			final int index, final boolean isSelected, final boolean cellHasFocus) {
		// TODO Auto-generated method stub
		super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
		this.setToolTipText(this.getText());
        final FreeOutlookList outlookList = (FreeOutlookList) list;
        if (outlookList.getFreeOutlookBar().getFreeOutlookPane().isShrinked()) {
            this.setBorder(shrinkedBorder);
            this.setText(null);
            this.setHorizontalAlignment(SwingConstants.CENTER);
            this.setIconTextGap(0);
        } else {
            this.setBorder(normalBorder);
            this.setHorizontalAlignment(SwingConstants.LEADING);
            this.setIconTextGap(5);
        }

        if (isSelected) {
            this.setBackground(selectedColor);
        }
        return this;
		
	}
}
